package com.zsr.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsr.example.entity.EduCollect;
import com.zsr.example.mapper.EduCollectMapper;
import com.zsr.example.service.EduCollectService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 课程收藏 服务实现类
 * </p>
 *
 * @author zsr
 * @since 2022-01-07
 */
@Service
public class EduCollectServiceImpl extends ServiceImpl<EduCollectMapper, EduCollect> implements EduCollectService {

    @Override
    public boolean isCollect(String memberId, String targetId, Integer targetType) {
        if (StringUtils.isEmpty(memberId)) return false;
        QueryWrapper<EduCollect> wrapper=new QueryWrapper<>();
        wrapper.eq("member_id",memberId);
        wrapper.eq("target_id",targetId);
        wrapper.eq("target_type",targetType);
        EduCollect collect = this.getOne(wrapper);
        return !ObjectUtils.isEmpty(collect);
    }
}
